package com.cn.zengzeng.spbzengzeng.controller.queue;

import com.cn.zengzeng.spbzengzeng.test.CallbackSender;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author: zengzeng
 * @Date: 2020/11/17 0017 14:37
 */
@RestController
@Slf4j
@Api(value = "MQ相关信息操作")
public class ProducerController {

    @Resource
    private RabbitTemplate rabbitTemplate;
    @Resource
    private CallbackSender callbackSender;
    @GetMapping("/msg")
    public String msg (String userInfo) {
        log.info("请求发送的参数是......................" + userInfo);
        if(userInfo != null) {
            rabbitTemplate.convertAndSend("topic.messages",userInfo);
            return "send ok";
        }
        return "send no ok";
    }

    @GetMapping("/msg1")
    public String msg1 () {
        callbackSender.send("","","");
        return "send no ok";
    }

}
